<!--  -->
<template>
  <div class="container">
    <div class="header">
      <el-input v-model="input" placeholder="请输入员工姓名" clearable  > 
        <i slot="prefix" class="el-input__icon el-icon-search" ></i>
      </el-input>
      <div class="right"> 
          <el-link type="danger" class="elink" >批量删除</el-link>
          <el-divider direction="vertical"></el-divider>
          <el-link type="primary" class="elink">批量启售</el-link>
          <el-divider direction="vertical"></el-divider>
          <el-link type="danger"  class="elink">批量停售</el-link>
        <el-button icon="el-icon-plus" style="margin-left: 20px;" @click="$router.push({name:'ChangeEmployee',})">新建菜品</el-button>
      </div>
    </div>

    <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="name" label="员工姓名"> </el-table-column>
        <el-table-column prop="username" label="账号"> </el-table-column>
        <el-table-column prop="phone" label="手机号"> </el-table-column>
        <el-table-column label="账号状态">
          <template slot-scope="scope">
            {{ scope.row.status ? "正常" : "已禁用" }}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-link type="primary"  @click="$router.push({name:'ChangeEmployee', query:{isEdit: '1'}})">编辑</el-link>
            <el-divider direction="vertical"></el-divider>
            <el-popconfirm  title="确认调整该账号的？" @onConfirm="handleChangeStatus(scope.row)">
              <el-link slot="reference" type="danger" >
              {{ scope.row.status ? "正常" : "已禁用" }}
            </el-link>
  </el-popconfirm>
  
  
            
          </template>
        </el-table-column>
      </el-table>
   <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.page"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
  
</template>

<script>
import { getDish} from "@/api/dish";
export default {
     data() {
    return {
      input: "",
      tableData: [],
      currentPage4: 4,
      pageInfo: {
        page: 1,
        pageSize: 10,
      },
      total: 0,

    };
  },
    created() {
      getData();
    },
    methods: {
      async getData() {
        const { data:{records,total}} = await getDish({...this.pageInfo,name:this.input,});
      this.tableData = records;
      this.total = total;
    },
      
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      handleSizeChange(val) {
      this.pageInfo.page = 1
      this.pageInfo.pageSize = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.pageInfo.page = val;
      this.getData();
    },
   
    }
    
  };
</script>
<style lang="scss" scoped>
.container {
  padding: 22px;
  .header {
    display: flex;
    justify-content: space-between;
  table{
    display: flex;
    justify-content: space-between;
  }
    .el-input {
      width: 250px;
    }
    .right .elink{
        margin:20px;
    }
  }
}
</style>